/*
 =============================================================================
 FILE...............: Flight.java
 COMMENTS...........: Model of a flight.
 =============================================================================
 AUTHOR(S)..........: Everton Ranielly de Sousa Cavalcante
 					  Department of Informatics and Applied Mathematics
 					  Federal University of Rio Grande do Norte
 LAST MODIFICATION..: September 26th, 2012
 ============================================================================= 					  
*/


/* ========================================================================= */
/* PACKAGES			                                                         */
/* ------------------------------------------------------------------------- */
package model;


/* ========================================================================= */
/* CLASS Flight				                                                 */
/* ------------------------------------------------------------------------- */
/**
 * Model of a flight
 * @author Everton Cavalcante
 */
public class Flight 
{
	private String airline;			// Airline name
	private String identification;	// Flight identification
	private Airport from;			// Departure airport
	private Airport to;				// Arrival airport
	private String flightDate;		// Departure date
	private String aircraft;		// Aircraft
	
	
	/** Default constructor */
	public Flight()
	{ /* Empty */ }
	
	
	/** Constructor */
	public Flight(String airline, String identification, String flightDate, Airport from, Airport to, 
		String aircraft)
	{
		if (((from.getAirportIATACode().length() == 0 && from.getAirportICAOCode().length() != 4) ||
			 (from.getAirportIATACode().length() != 3 && from.getAirportICAOCode().length() == 0)) && 
			((to.getAirportIATACode().length() == 0 && to.getAirportICAOCode().length() != 4) ||
			 (to.getAirportIATACode().length() != 3 && to.getAirportICAOCode().length() == 0)))
		{
			System.out.println("Invalid airport code");
			return;
		}
		else
		{
			this.setAirline(airline);
			this.setIdentification(identification);
			this.setFrom(from);
			this.setTo(to);
			this.setFlightDate(flightDate);
			this.setAircraft(aircraft);
		}
	}
	
	
	/**
	 * Returns the airline name 
	 * @return Airline name
	 */
	public String getAirline() 
	{ return airline; }
	
	
	/**
	 * Modifies the airline name
	 * @param airline Airline name to set
	 */
	public void setAirline(String airline) 
	{ this.airline = airline; }
	
	
	/**
	 * Returns the flight identification
	 * @return Flight identification
	 */
	public String getIdentification() 
	{ return identification; }
	
	
	/**
	 * Modifies the flight identification
	 * @param identification Flight identification to set
	 */
	public void setIdentification(String identification) 
	{ this.identification = identification; }

	
	/**
	 * Returns the departure airport
	 * @return Departure airport
	 */
	public Airport getFrom() 
	{ return from; }

	
	/**
	 * Modifies the departure airport
	 * @param from Departure airport to set
	 */
	public void setFrom(Airport from) 
	{ this.from = from; }

	
	/**
	 * Returns the arrival airport
	 * @return Arrival airport
	 */
	public Airport getTo() 
	{ return to; }

	
	/**
	 * Modifies the arrival airport
	 * @param to Arrival airport
	 */
	public void setTo(Airport to) 
	{ this.to = to; }

	
	/**
	 * Returns the flight date and time
	 * @return Flight date and time
	 */
	public String getFlightDate()
	{ return flightDate; }

	
	/**
	 * Modifies the flight date and time
	 * @param flightDate Flight date and time to set
	 */
	public void setFlightDate(String flightDate) 
	{ this.flightDate = flightDate; }


	/**
	 * Returns the type of aircraft used to operate the flight
	 * @return aircraft Type of aircraft
	 */
	public String getAircraft() 
	{ return aircraft; }


	/**
	 * Modifies the type of aircraft used to operate the flight
	 * @param aircraft Type of aircraft to set
	 */
	public void setAircraft(String aircraft) 
	{ this.aircraft = aircraft; }
	
	
	@Override
	public String toString()
	{
		String flight = "";
		flight += "Flight:\t\t" + this.getAirline() + " " + this.getIdentification() + "\n";
		flight += "From:\t\t\t" + this.getFrom().toString() + "\n";
		flight += "To:\t\t\t" + this.getTo().toString() + "\n";
		flight += "Departure:\t" + this.getFlightDate() + "\n";
		flight += "Aircraft:\t" + this.getAircraft();
		
		return flight;
	}
}
